from http.server import HTTPServer, BaseHTTPRequestHandler

class MyHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        # 设置响应状态码
        self.send_response(200)
        # 设置响应头
        self.send_header('Content-type', 'text/html')
        self.end_headers()
        # 发送响应内容
        self.wfile.write(b"Hello, world!")

# 设置服务器地址和端口
# server_address = ('localhost', 8000)
server_address = ('192.168.1.2', 8000)

httpd = HTTPServer(server_address, MyHandler)

print("Serving on port 8000...")
httpd.serve_forever()
    